package day12_coll.demo04_comparable;
//结论:
//用TreeSet存储对象,有参构造方法使用比较器进行排序
//比较器的实现，就是让集合构造接收Comparator接口的实现类，重写compare方法
//重写方法时,排序规则要按需求的主次条件来写
public class Student implements Comparable<Student> {
    @Override
    public int compareTo(Student o) {
        int sum=this.name.compareTo(o.getName());
        return sum;
    }
    private String name;
    private int age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public Student() {
    }


}
